<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <link rel="stylesheet" href="../layui/css/layui.css">
</head>
<body>
<button id="btn">测试</button>
<div class="site-demo-laydate" style="display: none">
  <div class="layui-inline" id="test-n1"></div>
</div>
</body>
<script src="../layui/layui.js"></script>
<script>
  window.onload = function (){
    layui.use('laydate', function() {
      var laydate = layui.laydate;
      //直接嵌套显示
      laydate.render({
        elem: '#test-n1'
        ,position: 'static'
        ,done: function(value, date, endDate){
              console.log(date); //得到日期时间对象：{year: 2017, month: 8, date: 18, hours: 0, minutes: 0, seconds: 0}
              site[0].style.display="none";
          }
          ,min:'2021-7-6'
          ,max:'2032-7-6'
      });

    });
    var btn = document.getElementById("btn");
    var site = document.getElementsByClassName("site-demo-laydate");
    btn.onclick = function (){
      site[0].style.display="block";
    }

  }
</script>
</html>